//
//  NBAMatchView.m
//  NBA
//
//  Created by Jaedong on 2018/3/16.
//  Copyright © 2018年 Jaedong. All rights reserved.
//

#import "NBAMatchView.h"
#import "NBAMatch.h"

@interface NBAMatchView ()
@property (weak) IBOutlet NSView *line;
@property (weak) IBOutlet NSTextField *player1Location;
@property (weak) IBOutlet NSImageView *player1Logo;
@property (weak) IBOutlet NSTextField *player1Name;
@property (weak) IBOutlet NSTextField *score;
@property (weak) IBOutlet NSTextField *titleOrTime;
@property (weak) IBOutlet NSImageView *player2Logo;
@property (weak) IBOutlet NSTextField *player2Name;
@property (weak) IBOutlet NSTextField *player2Location;

@end

@implementation NBAMatchView

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];
    
    // Drawing code here.
    _line.wantsLayer = YES;
    _line.layer.backgroundColor = [NSColor lightGrayColor].CGColor;
}

- (void)setViewDataWith:(NBAMatch *)match {
    _player2Location.stringValue = @"( 主 )";
    _player1Location.stringValue = @"( 客 )";
    _player2Logo.image = [NSImage imageNamed:match.homeTeam];
    _player1Logo.image = [NSImage imageNamed:match.awayTeam];
    _player2Name.stringValue = match.homeTeam;
    _player1Name.stringValue = match.awayTeam;
    _score.stringValue = [NSString stringWithFormat:@"%@ : %@", match.awayScore, match.homeScore];
    _titleOrTime.stringValue = [NSString stringWithFormat:@"%@ %@", match.statusDesc, match.time];
}

@end
